package com.asset.dispoal.company.service.commom;

import com.asset.dispoal.company.domain.db.entity.SysCompanyDo;
import com.asset.dispoal.company.domain.db.mapper.SysCompanyMapper;
import com.asset.dispoal.company.dto.CompanyResponse;
import com.asset.dispoal.company.service.converter.CompanyConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommandNoParam;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

/**
 * @author qr
 * @date 2022/1/25$
 */
@Component
public class CompanyCourtCommand implements BaseCommandNoParam<Result<List<CompanyResponse>>> {


    @Autowired
    SysCompanyMapper sysCompanyMapper;


    @Override
    public Result<List<CompanyResponse>> execute() {
        final List<SysCompanyDo> sysCompanyDos = sysCompanyMapper.queryCourtList();
        final List<CompanyResponse> responseList = CompanyConverter.INSTANCE.doToRes(sysCompanyDos);
        return Result.ok(responseList);
    }
}
